package com.kailong.servlet.student;

import com.kailong.dao.ManageReserve;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet("/student/doCancelReserve")
public class DoCancelReserve extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String sno = req.getParameter("sno");
        String tno = req.getParameter("tno");
        String name = req.getParameter("name");
        int count = 0;
        count = ManageReserve.cancelReserve(sno,tno);
        PrintWriter out = resp.getWriter();
        if (count>0){
            out.print("<script>");
            out.print("alert('取消预约成功！');window.location.href='reserveSelect' ");
            out.print("</script>");
        }else {
            out.print("<script>");
            out.print("alert('取消失败，如有疑问请在反馈建议处反馈！');");
            out.print("</script>");
        }
    }
}
